package zz.servlet;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.*;
import javax.xml.ws.Response;
import java.io.IOException;

//@Controller
//@RequestMapping("/login")
public class Login extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");

        String username = request.getParameter("username");
        String password = request.getParameter("password");
        if (username.equals("姜珊") && password.equals("123456")){
            response.sendRedirect(request.getContextPath() + "/multipartFileUpload.jsp");
//            request.getRequestDispatcher("/index.jsp").forward(request, response);
        }else {
            response.sendRedirect(request.getContextPath() + "/login.jsp");
//            request.getRequestDispatcher("/login.jsp").forward(request, response);
        }
    }
    protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

}
